<script type="text/javascript">
var _d = DialogManager.get('config_dialog');
_d.setWidth(540);
_d.setPosition('center');
var uploadpng = '{res file="images/upload.png"}';
$(function(){
	$('#add_image').click(function(){
		$(this).before('<div class="field_item"><div class="webkit-box file-box box-align-center">' +
            '<label>上传图片</label>' +
            '<p class="relative">' +
                '<input class="file absolute pointer" type="file" name="ad_image_file[]" onchange="loadImage(this)" />' +
                '<input type="hidden" name="ad_image_url[]" value="" />' +
                '<img src="' + uploadpng + '"/>' +
            '</p>' +
            '<font class="ml10 fs12" color="gray">点击图片上传,图片大小：968*260px</font>' +
            '<input class="ml20"  type="button" value="删除图片" onclick="drop_image(this)" /></div>' +
            '<div class="webkit-box mt10">' +
                '<label>链接地址</label>' +
                '<p><input type="text" name="ad_link_url[]" value="" /></p></div>' +
            '<div class="webkit-box mt10">' +
                '<label>标题</label>' +
                '<p><input type="text" name="ad_title_url[]" value="" /></p></div></div>');
	});
});
function drop_image(btnObj){
    $(btnObj).parents('.field_item').remove();
}
	
function loadImage(obj){
    getTempPath(obj,function(res){
        $(obj).parent().find('img').attr('src',res);
    });
}
</script>
<!-- {if $options} -->
<!-- {foreach from=$options item=image} -->
<div class="field_item">
    <div class="webkit-box file-box box-align-center">
        <label>上传图片</label>
        <p class="relative">
            <input class="file absolute pointer" type="file" name="ad_image_file[]" onchange="loadImage(this)" />
            <input type="hidden" name="ad_image_url[]" value="{$image.ad_image_url}" />
            <img src="{$image.ad_image_url|url_format}"/>
        </p>
        <font class="ml10 fs12" color="gray">点击图片上传,图片大小：995*350px</font>
        <input class="ml20"  type="button" value="删除图片" onclick="drop_image(this)" />
    </div>
    <div class="webkit-box mt10">
        <label>链接地址</label>
        <p><input type="text" name="ad_link_url[]" value="{$image.ad_link_url}" /></p>
    </div>
    <div class="webkit-box mt10">
        <label>标题</label>
        <p><input type="text" name="ad_title_url[]" value="{$image.ad_title_url}" /></p>
    </div>
</div>
<!-- {/foreach} -->
<!-- {else} -->
<div class="field_item">
    <div class="webkit-box file-box box-align-center">
        <label>上传图片</label>
        <p class="relative">
            <input class="file absolute pointer" type="file" name="ad_image_file[]" onchange="loadImage(this)" />
            <input type="hidden" name="ad_image_url[]" value="" />
            <img src="{res file='images/upload.png'}"/>
        </p>
        <font class="ml10 fs12" color="gray">点击图片上传,图片大小：995*350px</font>
    </div>
    <div class="webkit-box mt10">
        <label>链接地址</label>
        <p><input type="text" name="ad_link_url[]" value="" />
    </div>
    <div class="webkit-box mt10">
        <label>标题</label>
        <p><input type="text" name="ad_title_url[]" value="" /></p>
    </div>
</div>
<!-- {/if} -->
<input style="margin: 15px 0 10px; margin-left: 95px; height: 30px; line-height:19px; width: 100px;" id="add_image"  type="button" value="新增图片"/>
